package com.example.auth.service;

import com.example.auth.dto.TaskSubmissionDTO;
import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * Task submission service interface
 */
public interface TaskSubmissionService {

    /**
     * Submits a task file.
     * @param taskId The ID of the task.
     * @param file The uploaded file.
     * @param submitterId The ID of the submitter.
     * @param comment The submission comment.
     * @return The submission record DTO.
     */
    TaskSubmissionDTO submitTaskFile(Long taskId, MultipartFile file, Long submitterId, String comment);

    /**
     * Retrieves task submission records.
     * @param taskId The ID of the task.
     * @param userId The ID of the current user, used for permission filtering.
     * @return A list of submission records, filtered based on user permissions.
     */
    List<TaskSubmissionDTO> getSubmissionsByTaskId(Long taskId, Long userId);

    /**
     * Retrieves all task files submitted by a user.
     * @param submitterId The ID of the submitter.
     * @return A list of submission records.
     */
    List<TaskSubmissionDTO> getSubmissionsBySubmitterId(Long submitterId);

    /**
     * Retrieves submission details.
     * @param submissionId The ID of the submission.
     * @return The submission record DTO.
     */
    TaskSubmissionDTO getSubmissionById(Long submissionId);

    /**
     * Deletes a submission record.
     * @param submissionId The ID of the submission.
     * @return `true` if deletion was successful, `false` otherwise.
     */
    boolean deleteSubmission(Long submissionId);

    /**
     * Updates a submission comment.
     * @param submissionId The ID of the submission.
     * @param comment The new comment.
     * @return The updated submission record DTO.
     */
    TaskSubmissionDTO updateSubmissionComment(Long submissionId, String comment);

    /**
     * Checks if a task has been submitted.
     * @param taskId The ID of the task.
     * @return `true` if the task has been submitted, `false` otherwise.
     */
    boolean isTaskSubmitted(Long taskId);

    /**
     * Loads a file as a resource.
     * @param filePath The file path.
     * @return The file resource.
     */
    Resource loadFileAsResource(String filePath);
}